﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="barCode.aspx.cs" Inherits="Donal.Xms.Web.api.oauth.weixin.barCode" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta name="viewport" content="width=device-width; initial-scale=1.0; minimum-scale=1.0; maximum-scale=1.0" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>

    <script src="/scripts/jquery/jquery-1.11.2.min.js"></script>

    <style type="text/css">
        * {
            margin: 0;
            padding: 0;
            list-style: none;
            font-size: 14px;
        }

        html {
            height: 100%;
        }

        body {
            height: 100%;
            text-align: center;
        }

        .centerDiv {
            display: inline-block;
            zoom: 1;
            *display: inline;
            vertical-align: middle;
            text-align: left;
            padding: 10px;
        }

        .hiddenDiv {
            height: 100%;
            overflow: hidden;
            display: inline-block;
            width: 1px;
            overflow: hidden;
            margin-left: -1px;
            zoom: 1;
            *display: inline;
            *margin-top: -1px;
            _margin-top: 0;
            vertical-align: middle;
        }
    </style>
    <script>

        var isChecked = false;

        $(function () {
            var timer = setInterval(function () {
                if (isChecked == false) {
                    redirect();
                }
            }, 1000);
        });

        function redirect() {
            isChecked = true;

            $.ajax({
                type: "post",
                url: "/tools/submit_ajax.ashx?action=user_oauth_redirect_" + new Date().getTime(),
                data: { duid: $("[id^='hidCode']").val() },
                dataType: "json",
                success: function (data) {
                    if (data.status == 1) {
                        window.parent.location = $("#hidUrl").val();
                        return;
                    } else if (data.status == 2) {
                        
                        window.parent.location = data.msg;

                        return;
                    } else if (data.status == -1) {
                        alert(data.msg);
                        window.parent.location.reload();
                        return;
                    }

                    isChecked = false;
                }
            });
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:HiddenField ID="hidCode" runat="server" Value="0" />
        <asp:HiddenField ID="hidUrl" runat="server" Value="" />
    </form>
    <div class="centerDiv" style="text-align: center; font-family: 'Microsoft YaHei'">
        <asp:Image ID="barCodes" runat="server" Width="180" Height="180" />
    </div>
    <div class="hiddenDiv"></div>
</body>
</html>
